﻿using System.Collections.Generic;
using System.Linq;
using System.Web.Services;
using ACControl;

namespace DemoWebApplication
{
    /// <summary>
    /// Summary description for SuggestService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    [System.Web.Script.Services.ScriptService]
    public class SuggestService : WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }



        [WebMethod]
        public string[] GetWordSuggestions(string prefixText, int count, string contextKey)
        {
            //Set your Datasource for words that will suggested.
            //Manually entered here as sample, make a query to your database and get compitable words.
            var list = new Word();
            //var suggestions = (from w in StaticDatasource.MyDatasource
            //                   where w.Text.ToLower().Contains(prefixText.ToLower())
            //                   select new
            //                   {
            //                       w.WordId,
            //                       w.Text
            //                   });

            var myList = new List<string>();
            //foreach (var item in suggestions)
            //{
            //    myList.Add(AjaxControlToolkit.AutoCompleteExtender
            //        .CreateAutoCompleteItem(item.Text, item.WordId.ToString()));
            //}

            return myList.Skip(0).Take(count).ToArray();
        }
    }
}
